<template>
	<view class="my">
		<view class="top">
			<view class="avatar">
				<image :src="headImg" mode="aspectFit"></image>
			</view>
			<view class="name">
				欢迎您，{{name}}
			</view>
		</view>
		<view class="center">
			<u-cell-group>
				<u-cell icon="file-text-fill" title="日常检查列表" isLink="true" @click="goRecord('rc')"></u-cell>
				<u-cell icon="pushpin-fill" title="设备巡查列表" isLink="true" @click="goRecord('sb')"></u-cell>
				<u-cell icon="more-circle-fill" title="其他检查列表" isLink="true" @click="goRecord('qt')"></u-cell>
			</u-cell-group>
		</view>
		<view class="bottom">
			<u-button type="error" @click="layout">退出登录</u-button>
		</view>
	</view>
</template>

<script>
	export default{
		data() {
			return {
				name: '',
				headImg: ''
			}
		},
		onShow() {
			this.name = uni.getStorageSync('name')
			this.headImg = uni.getStorageSync('headImg') || '../../static/images/avatar.png'
		},
		methods: {
			goRecord(key) {
				uni.navigateTo({
					url: `./record?key=${key}`
				})
			},
			layout() {
				uni.showModal({
					title: '提示',
					content: '是否确定退出登录',
					success(res) {
						if (res.confirm) {
							uni.clearStorageSync()
							uni.reLaunch({
								url: '/pages/login'
							})
						}
					}
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	@import '../../common/style/main.less';
	.my {
		.top {
			background-color: @main-color;
			display: flex;
			align-items: center;
			padding: 30rpx 50rpx;
			color: #ffffff;
			border-radius: 0 0 60rpx 60rpx;
			.avatar {
				width: 100rpx;
				border: 6rpx solid #ffffff;
				border-radius: 50%;
				padding: 25rpx;
				margin-right: 30rpx;
				image {
					height: 100rpx;
				}
			}
		}
		.center {
			margin: 80rpx 0;
		}
		.bottom {
			width: 80%;
			margin: auto;
		}
	}
</style>